

/**
 * url  打开的路径  请使用绝对路径
 * options {
 *     height: 500,
 *     width : 700
 *   }
 */
function showDialogWindow(url,options) {
//	 alert("ddd")
	if(self != top){  
		return top.showDialogWindow(url,options);
	}
//	else if(null != window.dialogArguments){  
//		return window.dialogArguments.showDialogWindow(url,options);
//	}
	var dialogHeight = 500;
	var	dialogWidth  = 740;
	var settings ={};
	if(options){
		if(options.height){
			dialogHeight = options.height;
		}
		if(options.width){
			dialogWidth = options.width;
		}
	  $.extend(settings,options)
	}
	  mm = window.showModalDialog(
				url,
				self,
				'dialogHeight:'+dialogHeight+'px;dialogWidth:'+dialogWidth+'px;help:yes;status:no;toolbar:no;resizable:no;menubar:no;location:no;scroll:yes;dialogLeft:'
						+ (screen.width / 2.0 - 150) + ',dialogTop:100');	
	
	return  mm;
}


/* This function is used to open a pop-up window */
/**
 * url  打开的路径  请使用绝对路径
 * winTitle: open的窗口的名称
 * winParams  "left=0,top=0,directories,toolbar,scrollbars,resizable,status=yes";  
 */
function openWindow(url, winTitle, winParams) {
	winName = window.open(url, winTitle, winParams);
    winName.focus();
}

/**
 * 相同的winTitle 只打开一个窗口 
 * @param url
 * @param winTitle
 */
function openAlone(url,winTitle){
    var screenWidth = parseInt(screen.availWidth);
    var screenHeight = parseInt(screen.availHeight);
    var winParams = "width=" + screenWidth + ",height=" + screenHeight;
        winParams += ",left=0,top=0,directories,toolbar,scrollbars,resizable,status=yes";  
        openWindow(url, winTitle, winParams); 
	}

/**
 * 模拟 dialog的弹出窗口
 * @param url
 * @param options
 */
function openWindowAsDialog(url,options){
	var winTitle = "alone";
	var dialogHeight = 500;
	var	dialogWidth  = 740;
	if(options){
		if(options.height){
			dialogHeight = options.height;
		}
		if(options.title){
			winTitle = options.title;
		}
		if(options.width){
			dialogWidth = options.width;
		}
	}
	var winParams ='height='+dialogHeight+'px,width='+dialogWidth+'px,status=no,toolbar=no,resizable=no,menubar=no,location=no,scrollbars=yes,left='
	+ (screen.width / 2.0 -350) + ',top=100'
	openWindow(url, winTitle, winParams);
}
/**
 * 所有删除操作的提示
 * @param obj
 * @returns {Boolean}
 */
function confirmDelete(info) {   
	 var msg = "删除操作将不能恢复!您确定要继续?";
	 if(info){
		 msg = info
	 }
    ans = confirm(msg);
    if (ans) {
        return true;
    } else {
        return false;
    }
}
/**
 * 删除附件的提示
 * @param id
 */
function deleteAttachment(id){
	 if(confirm("确认删除？"))
	 {
	 $.post(appConfig.contPath+'/attachment/attachment!deletePnp.action',{id:id},function(data){
	         alert("删除成功！");
	        $("#attachment").hide();
	 });
	 }
}

/**
 * 删除附件的提示
 * @param id
 */
function deleteAttachmentById(id,tableId){
	 if(confirm("确认删除？"))
	 {
	 $.post(appConfig.contPath+'/attachment/attachment!deletePnp.action',{id:id},function(data){
	         alert("删除成功！");
	        $("#"+tableId).remove();
	 });
	 }
}

/**
* 流程提交时候的提示
*/
function isProcess(info){
	  var msg = "";
	if(!info){
		msg ="将提交该流程,是否继续";
	}else{
		msg =info+",是否继续!";
	}
    ans = confirm(msg);
    if (ans) {
        return true;
    } else {
        return false;
    }
}

function getUrlParms()    
{
    var args=new Object();   
    var query=location.search.substring(1);//获取查询串   
    var pairs=query.split("&");//在逗号处断开   
    for(var   i=0;i<pairs.length;i++)   
    {   
        var pos=pairs[i].indexOf('=');//查找name=value   
            if(pos==-1)   continue;//如果没有找到就跳过   
            var argname=pairs[i].substring(0,pos);//提取name   
            var value=pairs[i].substring(pos+1);//提取value   
            args[argname]=unescape(value);//存为属性   
    }
    return args;
}
   

/**获得系统时间*/
function getCurrentDate() {
      var   hours,   minutes,   seconds,   xfile;  
      var   intHours,   intMinutes,   intSeconds;  
      var   intYear,intMonth,intDate;  
      var   curYear,curMonth,curDate;  
      var   today;  
      today   =   new   Date();  
      intYear=today.getFullYear();  
      intMonth=today.getMonth();  
      intDate=today.getDate();  
 	  curYear=intYear+"年"
      curMonth=intMonth+1+"月";  
      curDate=intDate+"日"; 
      hours = intHours+":";
    
	  timeString =curYear+curMonth+curDate;
	  return timeString;
}

/**获得系统时间
 * 指定到某标签上*/	
function getCurrentDate2(dateId) { 
	  var   hours,   minutes,   seconds,   xfile;  
      var   intHours,   intMinutes,   intSeconds;  
      var   intYear,intMonth,intDate;  
      var   curYear,curMonth,curDate;  
      var   today;  
      today   =   new   Date();  
      intYear=today.getFullYear();  
      intMonth=today.getMonth();  
      intDate=today.getDate();  
      intHours   =   today.getHours();  
      intMinutes   =   today.getMinutes();  
      intSeconds   =   today.getSeconds();  
 	  curYear=intYear+"年"
      curMonth=intMonth+1+"月";  
      curDate=intDate+"日"; 
      hours = intHours+":";
      if  (intMinutes   <   10)   {  minutes   =   "0"+intMinutes+":";  }  
      else  {  minutes   =   intMinutes+":";  }  
      if (intSeconds   <   10)   {  seconds   =   "0"+intSeconds+"   ";   }  
      else  {  seconds   =   intSeconds+"   ";   }  
	  var   week=new   initArray("<font   color=RED>星期日</font>","<font   color=black>星期一</font>","<font   color=black>星期二</font>","<font   color=black>星期三</font>","<font   color=black>星期四</font>","<font   color=black>星期五</font>","<font color=GREEN>星期六</font>");
	  timeString =curYear+curMonth+curDate+hours+minutes+seconds+"   "+week[today.getDay()+1];
	  $("#currentDate").html(timeString);
}
function initArray() {
		this.length = initArray.arguments.length;
		for (var i = 0; i < this.length; i++) {
			this[i + 1] = initArray.arguments[i];
		}
	}



function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/* This function is used to set cookies */
function setCookie(name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
}

/* This function is used to get cookies */
function getCookie(name) {
	var prefix = name + "=" 
	var start = document.cookie.indexOf(prefix) 

	if (start==-1) {
		return null;
	}
	
	var end = document.cookie.indexOf(";", start+prefix.length) 
	if (end==-1) {
		end=document.cookie.length;
	}

	var value=document.cookie.substring(start+prefix.length, end) 
	return unescape(value);
}

/* This function is used to delete cookies */
function deleteCookie(name,path,domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

/**
 * 字符串操作的一些函数
 * @param str
 * @returns
 */
function strlength(str){
	return str.replace(/[^\x00-\xff]/gi,'xx').length;
}

String.prototype.Trim = function(){ 
	return this.replace(/(^\s*)|(\s*$)/g, ""); 
} 

String.prototype.LTrim = function(){ 
	return this.replace(/(^\s*)/g, ""); 
} 

String.prototype.RTrim = function(){ 
	return this.replace(/(\s*$)/g, ""); 
}

function hasChinese(obj) {
	var re = /[^\u4e00-\u9fa5]/;
	if (re.test(obj)) {
		return false;
	}
	return true;
}



 //调用：accAdd(arg1,arg2)
//返回值：arg1加上arg2的精确结果
function accAdd(arg1,arg2){
    var r1,r2,m;
    try{r1=arg1.toString().split(".")[1].length}catch(e){r1=0}
    try{r2=arg2.toString().split(".")[1].length}catch(e){r2=0}
    m=Math.pow(10,Math.max(r1,r2))
    return (arg1*m+arg2*m)/m
}
// 设置相加为(this).add(arg) 样式
Number.prototype.add = function (arg){
    return accAdd(arg,this);
}

//除法函数，用来得到精确的除法结果
//说明：javascript的除法结果会有误差，在两个浮点数相除的时候会比较明显。这个函数返回较为精确的除法结果。
//调用：accDiv(arg1,arg2)
//返回值：arg1除以arg2的精确结果
function accDiv(arg1,arg2){
    var t1=0,t2=0,r1,r2;
    try{t1=arg1.toString().split(".")[1].length}catch(e){}
    try{t2=arg2.toString().split(".")[1].length}catch(e){}
    with(Math){
        r1=Number(arg1.toString().replace(".",""))
        r2=Number(arg2.toString().replace(".",""))
        return (r1/r2)*pow(10,t2-t1);
    }
}

//给Number类型增加一个div方法，调用起来更加方便。
Number.prototype.div = function (arg){
    return accDiv(this, arg);
}

//乘法函数，用来得到精确的乘法结果
//说明：javascript的乘法结果会有误差，在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。
//调用：accMul(arg1,arg2)
//返回值：arg1乘以arg2的精确结果
function accMul(arg1,arg2)
{
    var m=0,s1=arg1.toString(),s2=arg2.toString();
    try{m+=s1.split(".")[1].length}catch(e){}
    try{m+=s2.split(".")[1].length}catch(e){}
    return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m)
}

//给Number类型增加一个mul方法，调用起来更加方便。
Number.prototype.mul = function (arg){
    return accMul(arg, this);
}

//减法函数，用来得到精确的除法结果
//说明：
//调用：accSub(arg1,arg2)
//返回值：arg1减arg2的精确结果
function accSub(arg1,arg2){
　　 var r1,r2,m,n;
　　 try{r1=arg1.toString().split(".")[1].length}catch(e){r1=0}
　　 try{r2=arg2.toString().split(".")[1].length}catch(e){r2=0}
　　 m=Math.pow(10,Math.max(r1,r2));
　　 //last modify by deeka
　　 //动态控制精度长度
　　 n=(r1>=r2)?r1:r2;
　　 return ((arg1*m-arg2*m)/m).toFixed(n);
}
//给Number类型增加一个sub方法，调用起来更加方便。
Number.prototype.sub = function (arg){
    return accSub(arg, this);
}

//整除
function intDiv(exp1, exp2)
{
    var n1 = Math.round(exp1); //四舍五入
    var n2 = Math.round(exp2); //四舍五入
    var rslt = n1 / n2; //除
    if (rslt >= 0) { rslt = Math.floor(rslt);} //返回值为小于等于其数值参数的最大整数值。
    else{ rslt = Math.ceil(rslt); } //返回值为大于等于其数字参数的最小整数。
    return rslt;
}

//给Number类型增加一个整除方法，调用起来更加方便。
Number.prototype.intDiv = function (arg){
    return intDiv(this, arg);
}	

function createMessageWindow() {
	$.window.prepare({
		   dock: 'left'       // change the dock direction: 'left', 'right', 'top', 'bottom'
		});
	$.window({
		title: "消息盒子",
		showFooter: false,
		maximizable:true,
		bookmarkable:false,
		showModal: true,
		width:700,
		height:420,
		resizable:false,
		showRoundCorner: true,
		createRandomOffset: {x:-1, y:-1},
		modalOpacity: 0.5,
		url: appConfig.contPath+"/app/messageinfo.action?sr=r&fontype=2"
	});
}
function ObusinessProjectInfoListWindow(){
	$.window.prepare({
		   dock: 'left'       // change the dock direction: 'left', 'right', 'top', 'bottom'
		});
	$.window({
		title: "工程列表选择",
		showFooter: false,
		maximizable:true,
		bookmarkable:false,
		width:700,
		height:450,
		resizable:false,
		showRoundCorner: true,
		createRandomOffset: {x:-1, y:-1},
		modalOpacity: 0.5,
		showModal: true,
		closable: false,
		minimizable:false,
		url: appConfig.contPath+"/obusiness/project/projectinfo!owerProjectWindows.action"
	});
}

function ProjectInfoList(){
	$.window.prepare({
		   dock: 'left'     // change the dock direction: 'left', 'right', 'top', 'bottom'
		});
	$.window({
		title: "工程列表选择",
		showFooter: false,
		maximizable:true,
		bookmarkable:false,
		width:700,
		height:450,
		x:-1,
		y:-1,
		createRandomOffset : {
			x : -1,
			y : -1
		},
		resizable:false,
		showRoundCorner: true,
		modalOpacity: 0.5,
		showModal: true,
		closable: false,
		minimizable:false,
		url: appConfig.contPath+"/project/projectinfo!windows.action"
	});
}
function ProInfoList(){
	$.window.prepare({
		   dock: 'left'     // change the dock direction: 'left', 'right', 'top', 'bottom'
		});
	$.window({
		title: "工程列表选择",
		showFooter: false,
		maximizable:true,
		bookmarkable:false,
		width:700,
		height:400,
		x:-1,
		y:-1,
		createRandomOffset : {
			x : -1,
			y : -1
		},
		resizable:false,
		showRoundCorner: true,
		modalOpacity: 0.5,
		showModal: true,
		closable: true,
		minimizable:false,
		url: appConfig.contPath+"/project/projectinfo!windows.action"
	});
}
function showWindow(titleName,url,options,onClose) {
	$.window.prepare({
		dock : 'left' // change the dock direction: 'left', 'right', 'top', 'bottom'
	});
	var dialogHeight = 500;
	var	dialogWidth  = 740;

	if(options){
		if(options.height){
			dialogHeight = options.height;
		}
		if(options.width){
			dialogWidth = options.width;
		}
	};
	
	$.window({
		title : titleName,
		showFooter : false,
		maximizable : true,
		bookmarkable : false,
		width : 760,
		height : 460,
		showRoundCorner : true,
		createRandomOffset : {
			x : -1,
			y : -1
		},
		onClose:onClose,
		modalOpacity : 0.5,
		resizable:false,
		showModal : true,
		closable : true,
		minimizable : false,
		url : url
	});
}

$(document).ready(function() {
	var col1_content =$("#col1_content");
	 if(col1_content.length){
		var col1_contenth = col1_content.innerHeight();
		var page_marginsh = $(".page_margins").innerHeight();
		  if (col1_contenth- page_marginsh < 0 ) {
			  col1_content.height(page_marginsh-100);
		  }
	 }else   {
		 var content =$("#colout");
		 if(content.length){
		   var contentth =content.innerHeight();
		   var pagemarginsh = $(".page_margins").innerHeight();
			  if (contentth- (pagemarginsh-90) < 0 ) {
				  content.height(pagemarginsh-90);
			  }
		 }
	 }
	});
function projectList(){
	location.href = appConfig.contPath+"/obusiness/project/projectinfo.action";
}

window.onbeforeunload = function (evt) {
	 if(window.opener) {
		if($.browser.msie){
			 if ((event.clientX +20> document.body.clientWidth)   &&   (event.clientY <0||event.altKey))  {
				 window.opener.location.reload();
			 }
		 }else {
			 window.opener.location.reload();
		 }
	 }
	 }
	 
	
	
